﻿using IterationLife.FootballTeaching.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.FootballTeachings {
    /// <summary>
    /// 课时数据传输对象扩展
    /// </summary>
    public static class LessonDtoExtension {
        /// <summary>
        /// 转换为课时实体
        /// </summary>
        /// <param name="dto">课时数据传输对象</param>
        public static Lesson ToEntity( this LessonDto dto ) {
            if ( dto == null )
                return new Lesson();
            return dto.MapTo( new Lesson( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为课时数据传输对象
        /// </summary>
        /// <param name="entity">课时实体</param>
        public static LessonDto ToDto(this Lesson entity) {
            if( entity == null )
                return new LessonDto();
            return entity.MapTo(new LessonDto());
        }
    }
}
